#define  _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int count = 0, i = 0, x = n;
	int a[100] = { 0 };
	int y = 0;
	for (i = 1;i <= n; i++)
	{
		a[i] = i;
	}
	do {
		for (i = 1; i <= n; i++)
		{
			if (a[i] != 0)
			{
				count++;
			}
			if (count == 3)
			{
				a[i] = 0;
				count = 0;
				x--;
				y = i;
			}
		}
	} while (x > 0);

	printf("%d", y);

	return 0;
}